{% extends 'base.html' %}
{% block title %}搜索结果 - Local Library{% endblock %}
{% block content %}
    <h1>搜索结果</h1>
    <form action="{% url 'book-search' %}" method="get" style="margin-bottom:16px;">
        <input type="text" name="q" value="{{ query }}" placeholder="搜索书名或作者" style="padding:4px 8px; border-radius:4px; border:1px solid #b0bec5;">
        <button type="submit" class="btn" style="padding:4px 12px;">搜索</button>
    </form>
    {% if query %}
        <p>与"<strong>{{ query }}</strong>"相关的图书：</p>
        {% if results %}
            <table>
                <tr>
                    <th>书名</th>
                    <th>作者</th>
                    <th>简介</th>
                </tr>
                {% for book in results %}
                <tr>
                    <td><a href="{% url 'book-detail' book.pk %}">{{ book.title }}</a></td>
                    <td>{{ book.author }}</td>
                    <td>{{ book.summary|truncatechars:40 }}</td>
                </tr>
                {% endfor %}
            </table>
        {% else %}
            <p>没有找到相关图书。</p>
        {% endif %}
    {% else %}
        <p>请输入关键词进行搜索。</p>
    {% endif %}
{% endblock %} 